<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        /* 
            解题思路：
                1. 分析需求;
                2. 编写代码;
                3. 调试代码;
        */

        // 将数组  ['关羽', '张飞', '程咬金','吕布']  转换为字符串
        var arr = ['关羽', '张飞', '程咬金', '吕布'];

        let result = "[";
        for (let index in arr) {
            // console.log(index, arr[index]);
            // result = result + "\'" + arr[index] + "\'" + ", ";
            // 最后一个元素单独处理
            if (index == arr.length - 1) {
                // console.log(arr[index] + "是最后一个元素");
                result = result + "\'" + arr[index] + "\'";
            } else {
                result = result + "\'" + arr[index] + "\'" + ", ";
            }
        }
        result = result + "]";
        console.log(result);

    </script>
</head>

<body>
    <input id='aa' name="qq">
 <!-- 键值对，k-v   key  value   -->
</body>

</html>
